<?php
include "header.php";
$_REQUEST['menu']="profile";
include "include.php";
include "menu.php";
?>
<div id="page">
	<div id="content">
	<div class="post">
	<p class="meta"><? echo $_REQUEST['tabname']?> profile</p>
	<div class="entry">
	<?php
	switch ($_REQUEST['profile_active']){
		case 0:
		$create_tab_sql="create table ".$_REQUEST['tabname']."(".
				"cmd_nm varchar(255) not null,
				 cmd_dis_key varchar(255) not null,
				 cmd_dis_type varchar(255) not null,
				 cmd_dis_type_arg varchar(255) not null,
				 cmd_dis_type_value_def varchar(255) not null,
				 cmd_write_file_method varchar(255) not null,
				 cmd_notices varchar(255) not null,
				 primary key(cmd_nm)
				 )";
		$create_tab_res=$dbconnect->query($create_tab_sql);
		is_error($create_tab_res);
		$update_program_name_sql="update program_name set status = 1 where id = '".$_REQUEST['program_id']."'";
		$update_program_name_res=$dbconnect->query($update_program_name_sql);
		is_error($update_program_name_res);
		$back_url="location: profile.php?profile_active=1&tabname=".$_REQUEST['tabname']."&program_id=".$_REQUEST['program_id'];
		header($back_url);
		break;
		case 1:
		$table_name=$_REQUEST['tabname'];
		$display_cmd_key_info=dbselectall($table_name);
		$tabid = "display_cmd_key_info";
		$tabth = array("cmd_name","cmd_display_key","cmd_display_value","cmd_write_file_method","cmd_notices");		
		$tabtd = array();
		for($i=0;$i<sizeof($display_cmd_key_info);$i++){
			switch($display_cmd_key_info[$i]["cmd_dis_type"]){
				case "input":
				$cmd_display_value="<input name='".$display_cmd_key_info[$i]["cmd_name"]."' size='".$display_cmd_key_info[$i]["cmd_dis_type_arg"]."'"
			}
		}
		echotable($tabid,$tabth,$tabtd);			
				
	}	
	?>
	</div>
	</div>
	<div class="post">
	<p class="meta">edit config-file command</p>
	<div class="entry">
	<form id="profile_edit" action="config_manager_actives.php" method="post">
	<table id="profile_edit">
	<tr>
	<th>command name</th>
	<th>command display key name</th>
	</tr>
	<tr>
	<td><input name="cmd_nm" size="30"></td>
	<td><input name="cmd_dis_key" size ="30"></td>
	</tr>
	   <tr>
        <th>command display key type</th>
        <th>command display key arge</th>
        </tr>
	<tr>
	<?php
	$dbtab_nm="cmd_key_type_def";
	$select_cmd_key_type_res=dbselectall($dbtab_nm);	
	?>
	<td><select name="cmd_dis_type">
	<?php
	for($i=0; $i<count($select_cmd_key_type_res); $i++){
	echo"<option value='".$select_cmd_key_type_res[$i]["key_type_name"]."'>".$select_cmd_key_type_res[$i]["key_type_name"]."</option>\n";
	}
	?>
	</select>
	</td>
	<td><input name="cmd_dis_type_arg" size="30"></td>
	</tr>
	<tr>
	<th>command display value def</th>
	<th>command write file method</th>
	</tr>
	<tr>
	<td><input name="cmd_dis_value_def" size="30"></td>
	<td><select name="cmd_write_file_method">
	<option value="double">double</option>
	<option value="value">value</option>
	<option value="key">key</option>
	</td>
	</tr>
	<tr>
	<th>command notices</th>
	<th></th>
	</tr>
	<tr>
	<td><input name="cmd_notices" size="30"></td>
	<td></td>
	</table>
	<input style="visibility:hidden" name="tabname" value="<?echo $_REQUEST['tabname']?>">
	<input style="visibility:hidden" name="profile_active" value="add_cmd_key">
	<input type="submit" value="new cmd">
	</form>
	</div>
	</div>
</div>
<div id="sidebar">
	<ul>
	<li>
	</li>
	</ul>
</div>
<div style="clear: both;">&nbsp;</div>
</div>
<?php
include "footer.php";
?>
